package com.uzai.console.web.alipaymch;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.taobao.api.internal.toplink.embedded.websocket.util.StringUtil;
import com.uzai.common.exception.BusinessException;
import com.uzai.common.result.ResponseCode;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.config.UzaiConsoleSysConfig;
import com.uzai.console.dto.alipaymch.AlipayMchAuthDto;
import com.uzai.console.dto.alipaymch.AlipayMchAuthIdDto;
import com.uzai.console.dto.alipaymch.AlipayMchAuthQuery;
import com.uzai.console.dto.alipaymchbatch.AlipayMchBatchDetailQuery;
import com.uzai.console.dto.alipaymchbatch.AlipayMchBatchQuery;
import com.uzai.console.entity.AlipayMchBatch;
import com.uzai.console.entity.AlipayMchBatchDetail;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.alipaymch.AlipayMchAppAuthService;
import com.uzai.console.service.alipaymch.AlipayMchBatchDetailService;
import com.uzai.console.service.alipaymch.AlipayMchBatchService;
import com.uzai.console.vo.alipaymch.AlipayMchAppAuthSignUrlVo;
import com.uzai.console.vo.alipaymch.AlipayMchAuthVo;
import com.uzai.console.vo.alipaymchbatch.AlipayMchBatchDetailVo;
import com.uzai.console.vo.alipaymchbatch.AlipayMchBatchVo;
import com.uzai.console.vo.base.SelectKeyVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.net.URLEncoder;

/**
 * 支付宝个人批量转账记录
 * @Auther: jianghan
 * @Date: 2021/12/14 14:04
 * @Description:
 */
@RestController
@Api(value = "个人支付宝转账记录",tags = "第三方支付宝|个人支付宝转账记录")
@ApiSort(101)
public class AlipayMchBatchController extends BaseController {
    private static Logger logger = LoggerFactory.getLogger(AlipayMchBatchController.class);

    @Autowired
    private AlipayMchBatchService alipayMchBatchService;
    @Autowired
    private AlipayMchBatchDetailService alipayMchBatchDetailService;

    @ApiOperation(value = "分页查询个人支付宝批量转账记录", notes = "分页查询个人支付宝批量转账记录", response = AlipayMchBatchVo.class)
    @ApiOperationSupport(order = 4)
    @PostMapping("/alipay/mchBatch/findAlipayMchBatchList")
    public Object findAlipayMchBatchList(@RequestBody AlipayMchBatchQuery alipayMchBatchQuery){
        return alipayMchBatchService.findAlipayMchBatchList(alipayMchBatchQuery);
    }

    @ApiOperation(value = "分页查询个人支付宝批量转账记录明细", notes = "分页查询个人支付宝批量转账记录明细", response = AlipayMchBatchDetailVo.class)
    @ApiOperationSupport(order = 4)
    @PostMapping("/alipay/mchBatchDetail/findAlipayMchBatchDetailList")
    public Object findAlipayMchBatchDetailList(@RequestBody AlipayMchBatchDetailQuery alipayMchBatchDetailQuery){
        if(StringUtils.isBlank(alipayMchBatchDetailQuery.getOutBatchNo())){
            throw new BusinessException(ResponseCode.BUSINESS_EXCEPTION, "请传入批次号");
        }
        if(alipayMchBatchDetailQuery.getMerId() == null){
            throw new BusinessException(ResponseCode.BUSINESS_EXCEPTION, "请传入运营商id");
        }
        return alipayMchBatchDetailService.findAlipayMchBatchDetailList(alipayMchBatchDetailQuery);
    }

}
